

import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;

import java.util.Iterator;
import java.util.List;

import org.hibernate.*;
public class Test {

 public static void main(String[] args) throws HibernateException, PortalException, SystemException {
	 Session session = null;
			session = HibernateUtil.getSessionFactory().getCurrentSession();

	 Transaction tx = session.beginTransaction();
	/* Date date1 = new Date();
		SimpleDateFormat  simpleFormat = new SimpleDateFormat("yyyy");
		System.out.println(simpleFormat.format(date1));	*/
	 
/*	 Etudiant etudiant=new Etudiant();
	 java.util.Date dateNaissance = new java.util.GregorianCalendar().getTime();
	 etudiant.setUserId(14377);
	 //etudiant.setDateNaissance(dateNaissance);
	   	session.createSQLQuery("insert into etudiant (userId,nomPere,metierPere,nomMere,metierMere,transportScolaire,CIN_tuteur,lieu_naissance,date_naissance,phone,adresse)" +
	   			"values ("+etudiant.getUserId()+",'"+etudiant.getNomPere()+"','"+etudiant.getMetierPere()+"','"+etudiant.getNomMere()+"','"+etudiant.getMetierMere()+"','"+etudiant.getTransportScolaire()+"','"+etudiant.getCinTuteur()+"','"+etudiant.getLieuNaissance()+"','"+etudiant.getDateNaissance()+"','"+etudiant.getAdresse()+"','"+etudiant.getPhone()+"')").executeUpdate();
*/
/*     eschoolModel.User e=(eschoolModel.User) session.createQuery("from User as u where u.userId=13011").list().get(0);
	   if (e==null)
	   {
		   System.out.print("e=null");
	   }
	   else{
	   	e.setMiddleName("jibo");
	   	session.saveOrUpdate(e);
	       tx.commit();
	   }*/
/*  Unite t = new Unite();
	t.setDescription("jj");
	t.setLibelle("math");
	t.setOrganizationId(12414);
	t.setNameOrg("s");
	 session.save(t);

	 List list = session.createQuery("from Compte").list();
	 Iterator it = list.iterator();
	 while (it.hasNext())
	 {
		 Compte e = (Compte)it.next();
	 System.out.println("id: "+e.getId()+"\nnom: "+ e.getNom()+"\nnumero :"+e.getNumero()+"\nsolde: "+e.getSolde());
	 }*/
	/*
	 List list = session.createQuery("from Etudiant").list();
	 Iterator it = list.iterator();
	 while (it.hasNext())
	 {
		 Etudiant e = (Etudiant)it.next();
		 if(e.getUser().getFirstName().equals("OP"))
		 {
			 Classe c= e.getClasses().iterator().next();
		 //e.setIdNiveau((long) 1);
			 	System.out.println("id: "+c.getNiveau().getNameNiveau());
		 }
	 }
	 tx.commit();
	// HibernateUtil.CloseSession();
	 * */
	 
	 System.out.print("ok");
 }
}